package com.study_online.mapper;/*
    张昊（java文件）
 
*/

import com.study_online.domain.Video;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;


import java.util.List;

@Mapper
@Repository
public interface VideoMapper {

    //根据视频id查询视频（与VideoTypeMapper表中的findAll()方法连用进行一对多查询）
    @Select("select * from video where vido_type_id=#{videTypeId}")
    List<Video> findById(@Param("videTypeId") int videTypeId);

    //根据视频id查询视频的路径
    @Select("select video_ip from video where vido_id=#{videoId}")
    String findVideoId(int videoId);

    //查询所有视频内容
    @Select("select * from video")
    List<Video> findAll();

    @Select("select video_introud from video where vido_id=#{videoId}")
    String findIntroud(Integer videoId);

    @Select("select noteid from video_note where videoid=#{videoId} and userid=#{userId}")
    Integer findIsNote(Integer videoId, Integer userId);

    @Update("insert into video_note(userid,videoid) values(#{videoId},#{userId})")
    void saveNote(Integer videoId, Integer userId);

    @Update("delete from video_note where noteid=#{noteid}")
    void delNote(Integer noteid);

    /*视频添加的mapper*/
    @Insert("insert into video (video_name,video_introud,vido_type_id,video_ip,picture_ip,video_pay,add_time) values" +
            "(#{videoName},#{videoIntroud},#{videoTypeId},#{videoIp},#{pictureIp},#{videoPay},#{addTime})")
    boolean insertData(String videoName, String videoIntroud, int videoTypeId, String videoIp, String pictureIp, String videoPay,String addTime);
}
